<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".del").click(function(){
		if (! confirm("确定删除？"))
		{
			return false;
		}
	});
});
</script>
<a href="<?=url('Product::Categories/List')?>">首页</a>
<?foreach ($ancestor as $a):?>
&gt; <a href="<?=url('Product::Categories/List', array('id' => $a['id']))?>"><?=$a['name']?></a>
<?endforeach;?>
<table width="100%" class="list_table">
<tr>
	<th>ID</th>
	<th>名称</th>
	<?php if(Helper_Plu_Number::$status):?><th>编号前缀</th><?php endif;?>
	<th>子级数量</th>
	<th>父级ID</th>
	<th>最后修改时间</th>
	<th>操作</th>
</tr>
<?foreach ($categories as $c):?>
<tr>
	<td><?=$c['id']?></td>
	<td>
		<?if ($c['children_count']):?>
		<a href="<?=url('Product::Categories/List', array('id' => $c['id']))?>"><?=$c['name']?></a>
		<?else:?>
		<?=$c['name']?>
		<?endif;?>
	</td>
	<?php if(Helper_Plu_Number::$status):?><td><?php echo $c['number_prefix'];?></td><?php endif;?>
	<td><?=$c['children_count']?></td>
	<td><?=$c['parent_id']?></td>
	<td><?=$c['last_edit_time']?></td>
	<td>
		<a href="<?=url('Product::Categories/Edit', array('id'=>$c['id']))?>">编辑</a>
		<a href="<?=url('Product::Categories/Create', array('id'=>$c['id']))?>">新建子类</a>
		<?if ( ! $c['children_count']):?>
		<a class="del" href="<?=url('Product::Categories/Delete', array('id'=>$c['id'], 'parent_id' => $c['parent_id']))?>">删除</a>
		<?endif;?>
	</td>
</tr>
<?endforeach;?>
</table>
<a href="<?=url('Product::Categories/Create', array('id' => (isset($_GET['id']) ? $_GET['id'] : '')))?>">添加分类</a>
<?php $this->_endblock();?>